<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%-- 
    JSP Name : mg_100_04.jsp
    Description : 관리자 관리 수정 페이지
    author Seung Won
    since 2012. 7. 23.
    version 1.0
    Modification Information
       since          author              description
    ===========    =============    ===========================
    2012. 7. 23.     Seung Won     최초 생성
--%>
<%@ include file="/WEB-INF/jsp/co/mn/include/declare.jspf" %>
<%@ include file="/WEB-INF/jsp/co/mn/include/session.jspf" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ko" lang="ko">
<head>
<%@ include file="/WEB-INF/jsp/co/mn/include/header.jspf" %>
<script type="text/javaScript" language="javascript">
<!--
$(document).ready(function() {
    /* form validation check */
    onloadCharCheck();
    
    $("#srchButn").bind("click", moveSearch);    // 검색
    $("#srchTxt").bind("keydown", eventEnter);    // 엔터키 제어
    $("#updButn").bind("click", updSubmit);    // 엔터키 제어
    $("#listButn").bind("click", moveList);    // 엔터키 제어
    $("#cnclButn").bind("click", formIniz);    // 엔터키 제어
    
    
    $("input[name='img']").click(function(){
        
        var idx = $("name[name='img']").index(this);
        updPw(idx);
     });
});

function moveList(){
    $("#mainForm").attr('action','/mg_100_01.do').submit();
}

/*
 * 페이징 
 */
function movePage(num) {
    $("#currentPageNo").val(num);
    $("#mainForm").attr('target','_self');
    $("#mainForm").attr('action','/mg_100_04.do').submit();
}

/*
 * 검색
 */
function moveSearch() {
    
    if (!isSchrChk($("#srchTxt").val())) {
        alert("검색어에는 특수문자를 입력할 수 없습니다.");
        $("#srchTxt").focus();
        return false;
    }
    
    if($("#srchTxt").val().length == 0) {
        alert("검색어를 입력해주세요.");
        $("#srchTxt").focus();
        return false;
    }
    
    $("#currentPageNo").val("1");
    $("#mainForm").attr('target','_self');
    $("#mainForm").attr('action','/mg_100_04.do').submit();
}

/*
 * 검색 Text EnterKey 처리
 */
function eventEnter() {
    if (event.key == 13) {
        moveSearch();
    }
}


/*
 * 비밀번호 초기화
 */
function updPw(argIdx) {
   
    if(argIdx == -1){
        return false;
    }
    $("#mbrIdx").val(argIdx);
    
    $("#currentPageNo").val("1");
    
    $("#mainForm").attr('target','comIframe');
    $("#mainForm").attr('action','/mg_100_06.do').submit();
}

/*
 * 수정처리
 */
function updSubmit() {
    
    if ($("input[name='arrIdx']").length < 1) return;
    
    if (!validateForm($("#mainForm"))) {
        return;
    }
    
    var updIdx = "";
    var updId = "";
    var updNm = "";
    var updEml = "";
    
    for (var i = 0; i < $("input[name='arrIdx']").length; i++){
        updIdx = updIdx + $("input[name='arrIdx']").eq(i).val() + ","; 
        updId = updId + $("input[name='arrId']").eq(i).val() + ",";
        updNm = updNm + $("input[name='arrNm']").eq(i).val() + ","; 
        updEml = updEml + $("input[name='arrEml']").eq(i).val() + ","; 
    }
    
    if (updIdx == "") {
        alert("수정할 항목을 선택해주세요.");
        return;
    }
    
    updIdx = updIdx.substring(0, updIdx.length-1);
    updId = updId.substring(0, updId.length-1);
    updNm = updNm.substring(0, updNm.length-1);
    updEml = updEml.substring(0, updEml.length-1);
    
    $("#updIdx").val(updIdx);
    $("#updId").val(updId);
    $("#updNm").val(updNm);
    $("#updEml").val(updEml);
    
    $("#mainForm").attr('target','comIframe');
    $("#mainForm").attr('action','/mg_100_07.do').submit();
}

/*
 * Form 초기화
 */
function formIniz() {
    document.mainForm.reset();
}
//-->
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>HMC GLOBAL CSR</title>
<meta name="description" content="" />
<meta name="keywords" content="" />
</head>
<body>
<div id="wrap">
    <!-- top -->
    <%@ include file="/WEB-INF/jsp/co/mn/include/top.jsp" %>
    <!-- top -->
 
    <!-- container -->
    <div id="container">
        <!-- LNB -->
        <%@ include file="/WEB-INF/jsp/co/mn/include/left.jsp" %>
        <!-- LNB -->
        <div id="contents">
            <form id="mainForm" name="mainForm" method="post">
            <input type="hidden" id="currentPageNo" name="currentPageNo" value="${paginationInfo.currentPageNo}" />
            <input type="hidden" id="mbrIdx" name="mbrIdx" value="" />
            <input type="hidden" id="updIdx" name="updIdx" value="" />
            <input type="hidden" id="updId" name="updId" value="" />
            <input type="hidden" id="updNm" name="updNm" value="" />
            <input type="hidden" id="updEml" name="updEml" value="" />
            <input type="hidden" id="updList" name="updList" value="Y" />
            <!-- location -->
            <%@ include file="/WEB-INF/jsp/co/mn/include/location.jsp" %>
            <!-- location -->
            <div class="searchWrap">
                <p class="pageResult flow">총&nbsp;<span>${paginationInfo.totalRecordCount}</span>건, 현재페이지 ${paginationInfo.currentPageNo}/${paginationInfo.totalPageCount} </p>
                <div class="search reverse">
                    <fieldset>
                        <legend class="invisible">Search</legend>
                        <select id="srchScn" name="srchScn">
                            <option value="" <c:if test="${rqInfo.srchScn == '' }"><c:out value="selected" /></c:if>>전체</option>
                            <option value="ID" <c:if test="${rqInfo.srchScn == 'ID' }"><c:out value="selected" /></c:if>>아이디</option>
                            <option value="NAME" <c:if test="${rqInfo.srchScn == 'NAME' }"><c:out value="selected" /></c:if>>이름</option>
                            <option value="EMAIL" <c:if test="${rqInfo.srchScn == 'EMAIL' }"><c:out value="selected" /></c:if>>이메일</option>
                        </select><input type="text" class="formSearch" id="srchTxt" name="srchTxt" value="${rqInfo.srchTxt }" title="검색어입력" minbyte="2" maxlength="10" /><input type="image" id="srchButn" name="srchButn" class="btnSearch" onClick="return;" src="/img/mng/btn/btn_search.gif" alt="검색" title="검색">
                    </fieldset>
                </div>
            </div>
            <table border="1" class="resultTable" summary="관리자 관리 표">
                <colgroup>
                    <col width="8%" />
                    <col width="18%" />
                    <col width="13%" />
                    <col width="32%" />
                    <col width="12%" />
                    <col width="17%" />
                </colgroup>
                <thead>
                    <tr>
                        
                        <th>번호</th>
                        <th>ID</th>
                        <th>이름</th>
                        <th>이메일</th>
                        <th>관리자 구분</th>
                        <th>비밀번호 초기화</th>
                    </tr>
                </thead>
                <tbody>
                    <c:choose>
                        <c:when test="${resultList != null && !empty resultList }">
                            <c:forEach var="result" items="${resultList }" varStatus="status">
                    <tr>
                        <td><input type="hidden" id="arrIdx" name="arrIdx" value="${result.mbrIdx }" />${result.blcNo }</td>
                        <td><input type="text" class="frmAdmin" id="arrId" name="arrId" value="${result.mbrId }" readonly nullable="true" /></td>
                        <td><input type="text" class="frmAdmin" id="arrNm" name="arrNm" value="${result.mbrNm }" readonly nullable="true" maxlength="13" /></td>
                        <td><input type="text" class="frmAdmin" id="arrEml" name="arrEml" value="${result.mbrEml }" nullable="true" maxlength="40" /></td>
                        <td>일반관리자</td>
                        <td><input type="image" name="img" onclick="updPw('${result.mbrIdx }');return false;" src="/img/mng/btn/btn_reset.gif" alt="비밀번호 초기화" title="비밀번호 초기화" /></td>
                    </tr>
                            </c:forEach>
                        </c:when>
                        <c:otherwise>
                    <tr>
                        <td colspan="6">등록된 내용이 없습니다.</td>
                    </tr>
                        </c:otherwise>
                    </c:choose>
                </tbody>
            </table>
            </form>
            <div class="btnBoard">
                <span class="flow">
                    <input type="submit" id="listButn" name="listButn" title="목록" value="목록" />
                </span>
                <span class="reverse">
                    <input type="submit" id="updButn" name="updButn" title="등록" value="등록" />
                    <input type="submit" id="cnclButn" name="cnclButn" title="취소" value="취소" />
                </span>
            </div>
            <div class="pageNate">
                <able:pagination paginationInfo="${paginationInfo }" type="image" jsFunction="movePage" />    
            </div>
        </div>
    </div>

 
    <<!-- footer -->
    <%@ include file="/WEB-INF/jsp/co/mn/include/bottom.jsp" %>
    <!-- /footer -->
</div>
</body>
</html>
